package cn.tedu.luban.settle.webapi.consumer;


import cn.tedu.luban.commons.pojo.order.dto.OrderMqDTO;
import cn.tedu.luban.settle.service.ISettleBillService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
@RocketMQMessageListener(
        topic = "${mq.topic.order-success-topic:order-success-topic}",
        consumerGroup = "${rocketmq.producer.group}")
public class OrderListener implements RocketMQListener<OrderMqDTO>, RocketMQPushConsumerLifecycleListener {

    @Resource
    private ISettleBillService settleBillService;

    @Override
    public void onMessage(OrderMqDTO settleDTO) {
        log.info("结算中心-待结算订单数据:{}",settleDTO);
        settleBillService.settle(settleDTO);
    }

    @Override
    public void prepareStart(DefaultMQPushConsumer consumer) {

    }
}









